﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace OASystem.DAL
{
    public interface IBaseRepository<T> : IDenpendecyRepository
    {
        /// <summary>
        /// 单表的添加一条记录
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Add(T entity);


        /// <summary>
        /// 单表的添加多条记录
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool AddRange(List<T> entities);



        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Delete(T entity);


        /// <summary>
        ///删除多个实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool BatchDelete(List<T> entities);



        /// <summary>
        ///删除多个实体根据Id
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool BatchDeleteById(params int[] ids);



        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Update(T entity);



        /// <summary>
        /// 查询返回一个集合
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        List<T> QueryList(Expression<Func<T, bool>> lambdaExpression);


        /// <summary>
        /// 查询返回一个对象,没有返回null---根据主键查
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        T Query(Expression<Func<T, bool>> lambdaExpression);


        /// <summary>
        ///判断是否存在
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Exists(Expression<Func<T, bool>> lambdaExpression);



        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        List<T> QueryPageList<S>(int pageIndex, int pageSize, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderbyLambda, out int count, bool isAsc = true);
    }
}
